package com.qzsoft.zhjd.laboratory.modules.laboratoryMechanicsYGroup.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.qzsoft.jeemis.common.utils.Result;
import com.qzsoft.zhjd.common.utils.ResultUtils;
import com.qzsoft.zhjd.laboratory.modules.laboratoryMechanicsYGroup.entity.MechanicsYGroupEntity;
import com.qzsoft.zhjd.laboratory.modules.laboratoryMechanicsYGroup.service.MechanicsYGroupService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

/**
 * 压力机数据
 */
@RestController
@RequestMapping("laboratory/mechanicsYGroup")
public class MechanicsYGroupController {

    @Autowired
    private MechanicsYGroupService mechanicsYGroupService;

    /**
     * 列表
     */
    @RequestMapping("/page")
//    @RequiresPermissions("laboratory:mechanicsYGroup:page")
    public Result page(@RequestParam Map<String, Object> params) {
        IPage page = mechanicsYGroupService.queryPage(params);
        return ResultUtils.ok(page);
    }


    /**
     * 信息
     */
    @RequestMapping("/find/{id}")
    @RequiresPermissions("laboratory:mechanicsYGroup:find")
    public Result find(@PathVariable("id") Integer id) {
        MechanicsYGroupEntity mechanicsYGroup = mechanicsYGroupService.getInfo(id);
        return ResultUtils.ok(mechanicsYGroup);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("laboratory:mechanicsYGroup:save")
    public Result save(@RequestBody MechanicsYGroupEntity mechanicsYGroup) {
        mechanicsYGroupService.saveData(mechanicsYGroup);
        return ResultUtils.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("laboratory:mechanicsYGroup:update")
    public Result update(@RequestBody MechanicsYGroupEntity mechanicsYGroup) {
        mechanicsYGroupService.updateData(mechanicsYGroup);
        return ResultUtils.ok();
    }


    /**
     * 删除单个
     */
    @RequestMapping("/delete/{id}")
    @RequiresPermissions("laboratory:mechanicsYGroup:delete")
    public Result deleteOne(@PathVariable("id") Integer id) {
        mechanicsYGroupService.deleteOneData(id);
        return ResultUtils.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("laboratory:mechanicsYGroup:delete")
    public Result delete(@RequestBody Integer[] ids) {
        mechanicsYGroupService.deleteData(Arrays.asList(ids));
        return ResultUtils.ok();
    }
}
